*STATA packages needed

*need the following STATA packages: ftools, reghdfe, outreg2, grc1leg, coefplot, stackdid, estpost
* use commands lookup, ssc, and install as needed to install these packages if do not already have them

*If not created already, create figures and tables folders where output is stored
capture mkdir "figures"
capture mkdir "tables"
capture mkdir "data"

*Also if not already set, set the directory for the main files, using the cd command
*For instance, "cd "C:\Users\replication\"

******************
*** MANUSCRIPT ***
******************

****************
*** Figure 1 ***
****************

*Evolution of COVID-19 Reponses, by Political Affiliation

clear
use "data_gallup.dta"

keep if gop==1 | dem==1
egen year_month=concat(year month), punc(-)
sort time gop
collapse (first) time time_string (min) min_time=time (max) max_time=time (mean) Mostly_Isol v_worry_ill worn_mask mostly_remote [aw=WEIGHT], by(year_month gop)
keep time year_month gop Mostly_Isol v_worry_ill worn_mask mostly_remote
sort gop time

foreach x in Mostly_Isol v_worry_ill worn_mask mostly_remote {
egen min_`x'=min(time) if `x'!=.
egen max_`x'=max(min_`x')
}

drop if year_month==""
drop if gop==.

sort gop time 

gen time_string=time
format time_string %td

twoway line v_worry_ill time_string if time>min_v_worry_ill & gop==0,  connect(direct) lcolor(blue*.6)  ///
|| line v_worry_ill time_string if time>min_v_worry_ill & gop==1,  connect(direct) lcolor(red*.6) lpattern(dash)  ///
saving(g1, replace)  ytitle("") ///
xtitle("") xlabel(21993(120)22508, grid gmax labgap(tiny)) ///
plotregion(color(white)) graphregion(color(white)) ///
xline(22325 22354 22389 , lwidth(.5in) lc(gray*.2)) ///
xline(22325 22389, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
legend(label(2 "Republican") label(1 "Democrat") row(1) pos(6))  ///
title("Very worried over COVID", span) 

twoway  line  Mostly_Isol time_string if time>min_Mostly_Isol & gop==0,  connect(direct) lcolor(blue*.6)  ///
|| line Mostly_Isol time_string if time>min_Mostly_Isol & gop==1,  connect(direct) lcolor(red*.6)  lpattern(dash) ///
 saving(g2, replace)  ytitle("") ///
xtitle("") xlabel(21993(120)22508, grid gmax labgap(tiny)) ///
plotregion(color(white)) graphregion(color(white)) ///
xline(22325 22354 22389 , lwidth(.5in) lc(gray*.2)) ///
xline(22325 22389, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
legend(label(2 "Republican") label(1 "Democrat"))  ///
title("Mostly isolating", span) 

twoway line  worn_mask time_string if time>min_worn_mask & gop==0,  connect(direct) lcolor(blue*.6)  ///
|| line  worn_mask time_string if time>min_worn_mask & gop==1,  connect(direct) lcolor(red*.6)  lpattern(dash) ///
saving(g3, replace) ytitle("") ///
xtitle("") xlabel(21993(120)22508, grid gmax labgap(tiny)) ///
plotregion(color(white)) graphregion(color(white)) ///
xline(22325 22354 22389 , lwidth(.5in) lc(gray*.2)) ///
xline(22325 22389, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
legend(label(2 "Republican") label(1 "Democrat"))  ///
title("Worn mask", span) 

twoway  line  mostly_remote time_string if time>min_mostly_remote & gop==0,  connect(direct) lcolor(blue*.6)  ///
|| line  mostly_remote time_string if time>min_mostly_remote & gop==1,  connect(direct) lcolor(red*.6)  lpattern(dash) ///
saving(g4, replace) ytitle("") ///
xtitle("") xlabel(21993(120)22508, grid gmax labgap(tiny)) ///
plotregion(color(white)) graphregion(color(white)) ///
xline(22325 22354 22389 , lwidth(.5in) lc(gray*.2)) ///
xline(22325 22389, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
legend(label(2 "Republican") label(1 "Democrat"))  ///
title("Mostly working remote", span) 

grc1leg  g2.gph g3.gph g1.gph   g4.gph , ///
imargin(0.5 0.5 0.5 0.5) row(2) col(2) legendfrom(g1.gph) iscale(*.75) ///
plotregion(color(white)) graphregion(color(white)) 
graph export "figures\Figure 1.png", replace width(2000) height(1500)

* Delete the intermediate files
erase g1.gph
erase g2.gph
erase g3.gph
erase g4.gph

*****************************
*** Figure 2 and Table S9 ***
*****************************

*Change in Partisan Gap in COVID-19 Responses

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

label variable age10 "Age (continuous)"
label variable age_group4 "Age 65 and up (indicator)"
label variable ZLNpc_new_cases_7day "Log Per capita COVID cases"
label variable somecol "Some college"
label variable Y3h6_facialcoverings "Mask required outside home"
label variable out_workforce "Out of workforce"
label variable income "Income"
label variable AmerInd "American Indian of Native Hawaiian"
label variable Yc4_restrictionsongatherings "Restrictions on social gathering in effect"
label variable indep_third "Independent respondent"

*Mostly Isolate

estimates clear

reghdfe Mostly_Isol dmonthdum3-dmonthdum20 dem indep_third imonthdum3-imonthdum20 ZLNpc_new_cases_7day employed out_workforce live_w_children income male age10 age_group4 somecol ba grad AmerInd Asian Black Hisp Multiracial Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(time ctyfip) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3) replace
estimates store nofes

reghdfe Mostly_Isol  dmonthdum3-dmonthdum20 dem indep_third imonthdum3-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)
estimates store fes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("MostlyIsolate", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")


*Worn Mask

estimates clear

reghdfe worn_mask  dmonthdum4-dmonthdum20 dem indep_third imonthdum4-imonthdum20 ZLNpc_new_cases_7day out_workforce employed live_w_children income  Y3h6_facialcoverings male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)
estimates store nofes

reghdfe worn_mask dmonthdum4-dmonthdum20 dem indep_third imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4  , a(time pid) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)
estimates store fes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")


*Very Worried Ill

estimates clear

reghdfe v_worry_ill dmonthdum4-dmonthdum20 dem indep_third imonthdum4-imonthdum20 ZLNpc_new_cases_7day out_workforce employed live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial  [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)
estimates store nofes

reghdfe v_worry_ill dmonthdum4-dmonthdum20 dem indep_third imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4  , a(time pid) vce(cl ctyfip)
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)
estimates store fes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Worry", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")


*Mostly Remote

estimates clear

reghdfe mostly_remote dmonthdum5-dmonthdum20  dem indep_third imonthdum5-imonthdum20 ZLNpc_new_cases_7day  live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial  if  employed==1 [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)

reghdfe mostly_remote dmonthdum5-dmonthdum20 dem indep_third imonthdum5-imonthdum20  ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1, a(time pid) vce(cl ctyfip)
estimates store fes
outreg2 using "tables\Table S9.xls", excel adjr2 lab dec(3)

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
yscale(range(-.3 .2)) ylabel(-.3(.1).2) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Remote", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate.gph Mask.gph Worry.gph Remote.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure 2.png", replace width(2200) height(1600)

* Delete the intermediate files
erase MostlyIsolate.gph
erase Mask.gph
erase Worry.gph
erase Remote.gph


***************
*** Table 1 ***
***************

*Pre- versus Post- Vaccination Status, Difference-in-Differences

clear
use "data_gallup.dta"

// Key variables
gen vac_dem=vaccinated*dem
gen vac_ind=vaccinated*indep_third
gen vac_gop=vaccinated*gop

label variable vac_dem "Vaccinated x Democrat"
label variable vac_ind "Vaccinated x Independent"
label variable vaccinated "Vaccinated"

**Top panel
// Estimate TWFE model on ever and never treated
reghdfe Mostly_Isol vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table 1 TOP PANEL.xls", excel adjr2 lab dec(3) replace keep(vac_dem vac_ind vaccinated)
reghdfe worn_mask vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table 1 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe v_worry_ill vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table 1 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe mostly_remote vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT] if employed==1,  a(pid time) vce(cl pid)
outreg2 using "tables\Table 1 TOP PANEL.xls", excel adjr2 lab dec(4) keep(vac_dem vac_ind vaccinated)

**Lower panel
//Estimate Stacked DID on ever and never treated

clear
use "stacked_did_data_never_treated.dta"

label variable dem_vac "Vaccinated x Democrat"
label variable ind_vac "Vaccinated x Independent"
label variable vaccinated "Vaccinated"

gen _cohort_unit = st_unit
gen _cohort_time = st_time
gen _cohort = Cohort

*Note these lines below can take several minutes to run.

* Estimate Stacked DID
stackdid Mostly_Isol dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table 1 LOWER PANEL.xls", excel adjr2 lab dec(3) replace keep(dem_vac ind_vac vaccinated)
stackdid worn_mask dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table 1 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)
stackdid v_worry_ill dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table 1 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)
stackdid mostly_remote dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements if employed==1 [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table 1 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)


**************
** Table 2 ***
**************

*Individual Approval of State Response

clear
use "data_gallup.dta"

*GOP governors only
reghdfe approvestate dem indep ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) replace keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate  dem indep demrestrictionsongatherings Yc4_restrictionsongatherings indrestrictionsongatherings  ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate  dem indep demstay Yc6_stayathome indstay ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*DEM governors only
reghdfe approvestate gop indep ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income  if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate  gop indep goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings  ///
ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table 2.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)



*****************************
*** SUPPLEMENTAL APPENDIX ***
*****************************

*(note that S1, S4, and S8 are not tables or figures)

****************
*** Table S2 ***
****************

*Distribution of Survey Participation by Number of Responses per Individual

clear
use "data_gallup.dta"

egen uni=tag(pid)
total uni
sum pid uni
bysort pid: egen interviews = count(month)
collapse (count) Observations = uni, by(interviews)
rename interviews Number_of_responses
su Observations, meanonly
gen Percent = round(100 * Observations / r(sum), 0.01)
tostring Number_of_responses, replace force
su Observations, meanonly
local total_obs = r(sum)
expand 2 if _n == 1
replace Number_of_responses = "Total" if _n == _N
replace Observations = `total_obs' if _n == _N
replace Percent = 100 if _n == _N

export excel using "tables\Table S2.xls", firstrow(variables) replace


*****************
*** Figure S3 ***
*****************

*Full and partial vaccination status by party by month

clear
use "data_gallup.dta"

keep if gop==1 | dem==1
egen year_month=concat(year month), punc(-)

sort time gop
collapse (first) time  time_string (min) min_time=time (max) max_time=time ///
(mean) vaccinated fullvac [aw=WEIGHT], by(year_month gop)

keep time  year_month gop vaccinated fullvac
sort gop time

foreach x in vaccinated  fullvac {
egen min_`x'=min(time) if `x'!=.
egen max_`x'=max(min_`x')
}

sort gop time 

gen time_string=time
format time_string %td

sort gop time 

twoway  line  vaccinated time_string if time>22264 & gop==0,  connect(direct) lcolor(blue)  ///
|| line  vaccinated time_string if time>22264 & gop==1,  connect(direct) lcolor(red*.6)  lpattern(longdash) ///
||  line  fullvac time_string if time>22264 & gop==0,  connect(direct) lcolor(blue) lpattern(dash_dot) ///
|| line  fullvac time_string if time>22264 & gop==1,  connect(direct) lcolor(red*.6)  lpattern(shortdash) ///
ytitle("") ///
xtitle("") xlabel(22264(60)22508, grid gmax labgap(tiny)) ///
xline(22325 22354 22389 , lwidth(.5in) lc(gray*.2)) ///
xline(22325 22389, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
plotregion(color(white)) graphregion(color(white)) ///
legend(label(2 "Republican: any vaccination") label(1 "Democrat: any vaccination") label(3 "Democrat: fully") label(4 "Republican: fully")  rows(2) pos(6)) ///
title("Vaccination status by party identification", span) 
graph export "figures/Figure S3.png", replace



****************
*** Table S5 ***
****************

*Descriptive Statistics 

clear
use "data_gallup.dta"

label variable dem "Democrat"
label variable gop "Republican"
label variable indep_third "Independent (or third party)"
label variable Yc6_stayathomerequirements "Stay-at-home-order"
label variable vaccinated "Vaccination status"

estpost summarize Mostly_Isol worn_mask v_worry_ill mostly_remote ///
dem indep_third gop ///
LNpc_new_cases_7day ZLNpc_new_cases_7day employed out_workforce live_w_children income ///
male age10 age_group4 somecol ba grad AmerInd Asian Black Hisp Multiracial ///
Y3h6_facialcoverings Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing vaccinated [aw=WEIGHT]

esttab using "tables\Table S5.csv", label cells("count mean(fmt(2)) sd(fmt(2))") replace nonumber noobs

*Skewness of COVID cases - as per notes of Table S5 
clear
use "COVID_data_from_USA_Facts.dta"

* Skewness of covid cases
sum pc_new_cases_7day, detail

* Skewness of covid cases - logged
gen ln_pc_new_cases=log(pc_new_cases_7day+1)
sum ln_pc_new_cases, detail


****************
*** Table S6 ***
****************

*Descriptive Statistics of Individual-level COVID-19 Responses by Party

clear
use "data_gallup.dta"

estpost summarize Mostly_Isol worn_mask v_worry_ill mostly_remote approve [aw=WEIGHT] if dem==1
estimates store dems

estpost summarize Mostly_Isol worn_mask v_worry_ill mostly_remote approve [aw=WEIGHT] if gop==1
estimates store reps

estpost summarize Mostly_Isol worn_mask v_worry_ill mostly_remote approve [aw=WEIGHT] if indep_third==1
estimates store inds

esttab dems reps inds using "tables\Table S6.csv", label ///
    cells("count mean(fmt(2))  sd(fmt(2))") replace ///
    nonumber noobs ///
    mtitles("Democrats" "Republicans" "Independents")


****************
*** Table S7 ***
****************

*Comparison of Demographic Descriptive Statistics across Samples

bysort pid: egen interviews = count(month)

local vars employed out_workforce live_w_children income ///
male age10 age_group4 somecol ba grad Black Hisp Asian AmerInd Multiracia
estpost summarize `vars' [aw=WEIGHT]
estimates store full

estpost summarize `vars' [aw=WEIGHT] if interviews > 1
estimates store nosingletons

esttab full nosingletons using "tables\Table S7.csv", label ///
    cells("mean(fmt(2))") replace ///
    nonumber noobs ///
    mtitles("Full sample" "Mean excluding singleton responses")


****************
*** Table S9 ***
****************

*Parameter Estimates for Figure 2. Table created together with Figure 2 -see above


******************
*** Figure S10 ***
******************

*Change in Partisan Gap in COVID-19 Responses, Excluding Party-Switchers
*note that in regressions with individual fixed effects for non-party switchers, main effects of party not included (and would drop out) because party switchers not included

clear
use "data_gallup.dta"

keep if partyswitch==0

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

global controls_fe_model "ZLNpc_new_cases_7day out_workforce employed income"
global controls_main_model "male age10 age_group4 live_w_children  somecol ba grad AmerInd Asian Black Hisp Multiracial"

*Mostly Isolate

estimates clear
reghdfe Mostly_Isol  dmonthdum3-dmonthdum20 imonthdum3-imonthdum20  Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_fe_model [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe Mostly_Isol dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20 Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model $controls_fe_model  [aw=WEIGHT],  a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("MostlyIsolate", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")

*Worn Masks

estimates clear
reghdfe worn_mask dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4  , a(time pid) vce(cl ctyfip)

estimates store fes
reghdfe worn_mask dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20 $controls_fe_model  Y3h6_facialcoverings $controls_main_model [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

*Very Worried Ill

estimates clear
reghdfe v_worry_ill dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe v_worry_ill dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20 $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model  [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Worry", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")


*Mostly Remote

estimates clear
reghdfe mostly_remote dmonthdum5-dmonthdum20 imonthdum5-imonthdum20  ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1, a(time pid) vce(cl ctyfip)
estimates store fes
reghdfe mostly_remote dem indep_third  dmonthdum5-dmonthdum20 imonthdum5-imonthdum20 ZLNpc_new_cases_7day  income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  $controls_main_model  if  employed==1 [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Remote", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate.gph Mask.gph Worry.gph Remote.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S10.png", replace width(2200) height(1600)

* Delete the intermediate files
erase MostlyIsolate.gph
erase Mask.gph
erase Worry.gph
erase Remote.gph


******************
*** Figure S11 ***
******************

*Change in Partisan Gap in COVID-19 Responses, Initial Party Identification

clear
use "data_gallup.dta"

bysort pid: gen firstinpanel=1 if _n==1
bysort pid: replace firstinpanel=0 if _n!=1

gen firstdem=1 if firstinpanel==1 & dem==1
replace firstdem=0 if firstinpanel==1 & dem==0
bysort pid (firstdem): replace firstdem= firstdem[1]

gen firstind=1 if firstinpanel==1 & indep_third==1
replace firstind=0 if firstinpanel==1 & indep_third==0
bysort pid (firstind): replace firstind= firstind[1]

gen firstgop=1 if firstinpanel==1 & gop==1
replace firstgop=0 if firstinpanel==1 & gop==0
bysort pid (firstgop): replace firstgop= firstgop[1]

replace dem=firstdem
replace indep_third=firstind
drop dmonth imonth

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

gen dmonth=dem*month_number
gen imonth=indep_third*month_number

drop dmonthdum* imonthdum*

*recreate month X party dummies with initial party ID
tab dmonth, gen(dmonthdum)
tab imonth, gen(imonthdum)

*Mostly Isolate
estimates clear
reghdfe Mostly_Isol  dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20  Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_fe_model [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe Mostly_Isol dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20 Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model $controls_fe_model  [aw=WEIGHT],  a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("MostlyIsolate", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")

*Worn Masks

estimates clear
reghdfe worn_mask dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe worn_mask dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20 $controls_fe_model  Y3h6_facialcoverings $controls_main_model [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

*Very Worried Ill

estimates clear
reghdfe v_worry_ill dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe v_worry_ill dem indep_third dmonthdum2 dmonthdum4-dmonthdum20 imonthdum2 imonthdum4-imonthdum20 $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model  [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Worry", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")

*Mostly Remote

estimates clear
reghdfe mostly_remote dem indep_third dmonthdum5-dmonthdum20 imonthdum5-imonthdum20  ZLNpc_new_cases_7day  live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1, a(time ctyfip pid) vce(cl ctyfip)
estimates store fes

reghdfe mostly_remote dem indep_third dmonthdum5-dmonthdum20 imonthdum5-imonthdum20 ZLNpc_new_cases_7day  live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  $controls_main_model  if  employed==1 [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Remote", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate.gph Mask.gph Worry.gph Remote.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S11.png", replace width(2200) height(1600)

* Delete the intermediate files
erase MostlyIsolate.gph
erase Mask.gph
erase Worry.gph
erase Remote.gph



******************
*** Figure S12 ***
******************

*Change in Partisan Gap in COVID-19 Responses, with Fixed Effects for Date × County

*Note that these regressions can take several minutes to run

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)


*Mostly Isolate

estimates clear
reghdfe Mostly_Isol  dmonthdum3-dmonthdum20 imonthdum3-imonthdum20  Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_fe_model [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe Mostly_Isol dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20 Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model $controls_fe_model  [aw=WEIGHT],  a(time ctyfip cty_x_time) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("MostlyIsolate", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")


*Worn Masks

estimates clear
reghdfe worn_mask dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe worn_mask dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20 $controls_fe_model  Y3h6_facialcoverings $controls_main_model [aw=WEIGHT], a(time ctyfip cty_x_time) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")


*Very Worried Ill

estimates clear
reghdfe v_worry_ill dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20  $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe v_worry_ill dem indep_third dmonthdum4-dmonthdum20 imonthdum4-imonthdum20 $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model  [aw=WEIGHT], a(time ctyfip cty_x_time) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Worry", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")


*Mostly remote

estimates clear
reghdfe mostly_remote dem indep_third  dmonthdum5-dmonthdum20 imonthdum5-imonthdum20  ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1, a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe mostly_remote dem indep_third  dmonthdum5-dmonthdum20 imonthdum5-imonthdum20 ZLNpc_new_cases_7day  income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  $controls_main_model  if  employed==1 [aw=WEIGHT], a(time ctyfip cty_x_time) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Remote", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate.gph Mask.gph Worry.gph Remote.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S12.png", replace width(2200) height(1600)

* Delete the intermediate files
erase Remote.gph
erase MostlyIsolate.gph
erase Mask.gph
erase Worry.gph


******************
*** Figure S13 *** 
******************

*Change in Partisan Gap in COVID-19 Responses, States with Mask Mandates

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)

*no individual fixed effects
estimates clear
reghdfe worn_mask dem indep_third   dmonthdum4-dmonthdum20  imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed live_w_children income  male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial [aw=WEIGHT]  if Y3h6_facialcoverings==1 , a(time ctyfip) vce(cl ctyfip)
estimates store nofes

*individual fixed effects
reghdfe worn_mask dem indep_third   dmonthdum4-dmonthdum20  imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income [aw=WEIGHT]  if minmonthmask==4 & Y3h6_facialcoverings==1 , a(time pid) vce(cl ctyfip)
estimates store fes

quietly  coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
legend(position(6) rows(1)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask_Mandate_Only", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

graph export "figures\Figure S13.png", replace

* Delete the intermediate files
erase Mask_Mandate_Only.gph



***************************
*** Figures S14 and S15 *** 
***************************

*Month-party effects on COVID behaviors/attitudes for Democrats and Republicans, without individual fixed effects

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)



**MODELS
forvalues m=1/5 {
foreach v in a b {
foreach p in d g {
forvalues i=2/20 {
gen `p'coM`m'`v'`i'=.
gen `p'seM`m'`v'`i'=.
gen `p'ubM`m'`v'`i'=.
gen `p'lbM`m'`v'`i'=.
}
}
}
}

*Mostly Isolating

*M1-A-FixEff
quietly reghdfe Mostly_Isol  dem gop dmonthdum3-dmonthdum20 gmonthdum3-gmonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
forval i = 3/20 {
foreach p in d g {
foreach t in a {
foreach m in 1 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}

*M1-B-NO FixEff
quietly reghdfe Mostly_Isol  dem gop dmonthdum3-dmonthdum20 gmonthdum3-gmonthdum20  ZLNpc_new_cases_7day out_workforce employed live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]   ,  a(time ctyfip) vce(cl ctyfip)
forval i = 3/20 {
foreach p in d g {
foreach t in b {
foreach m in 1 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}


*Very Worry Ill

*M2-A-FixEff
quietly reghdfe v_worry_ill   dem gop dmonthdum4-dmonthdum20 gmonthdum4-gmonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4 ,  a(time pid) vce(cl ctyfip)
forval i = 4/20 {
foreach p in d g {
foreach t in a {
foreach m in 2 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}

*M2-B-NO FixEff
quietly reghdfe v_worry_ill   dem gop dmonthdum4-dmonthdum20 gmonthdum4-gmonthdum20   ZLNpc_new_cases_7day out_workforce employed live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4 ,  a(time ctyfip) vce(cl ctyfip)
forval i = 4/20 {
foreach p in d g {
foreach t in b {
foreach m in 2 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}


*Mostly Remote

*M3-A-FixEff
quietly reghdfe mostly_remote   dem gop dmonthdum5-dmonthdum20 gmonthdum5-gmonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT] if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1,  a(time pid) vce(cl ctyfip)
forval i = 5/20 {
foreach p in d g {
foreach t in a {
foreach m in 3 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}

*M3-B-NO FixEff
quietly reghdfe mostly_remote  dem gop dmonthdum2 dmonthdum5-dmonthdum20 gmonthdum2 gmonthdum5-gmonthdum20   ZLNpc_new_cases_7day out_workforce employed live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if  employed==1 ,  a(time ctyfip) vce(cl ctyfip)
forval i = 5/20 {
foreach p in d g {
foreach t in b {
foreach m in 3 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}


*Worne Mask

*M4-A-FixEff
quietly reghdfe worn_mask   dem gop dmonthdum2 dmonthdum4-dmonthdum20 gmonthdum2 gmonthdum4-gmonthdum20  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT] if minmonthmask==4,  a(time pid) vce(cl ctyfip)
forval i = 4/20 {
foreach p in d g {
foreach t in a {
foreach m in 4 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}

*M4-B-NO FixEff
quietly reghdfe worn_mask   dem gop dmonthdum2 dmonthdum4-dmonthdum20 gmonthdum2 gmonthdum4-gmonthdum20   ZLNpc_new_cases_7day out_workforce employed live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  ,  a(time ctyfip) vce(cl ctyfip)
forval i = 4/20 {
foreach p in d g {
foreach t in b {
foreach m in 4 {
replace `p'coM`m'`t'`i'=_b[`p'monthdum`i'] 
replace `p'seM`m'`t'`i'=_se[`p'monthdum`i'] 
replace `p'ubM`m'`t'`i'=`p'coM`m'`t'`i'+1.96*`p'seM`m'`t'`i' 
replace `p'lbM`m'`t'`i'=`p'coM`m'`t'`i'-1.96*`p'seM`m'`t'`i' 
}
}
}
}


collapse  dco* gco* dse* gse* dub* dlb*  gub* glb*

gen n=1
reshape long dco gco dse gse gub glb dub dlb, i(n) j(type) string
tab type
gen mnum=substr(type,4,2)
gen fig=substr(type,1,3)
tab mnum
tab fig
destring mnum, replace

save "data\model_results_for_fig2_plots_dem_v_gop.dta", replace
use "data\model_results_for_fig2_plots_dem_v_gop.dta", clear


*Mostly Isolating-FIX Ef A
twoway rcap gub glb mnum if fig=="M1a", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M1a", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M1a", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M1a", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("MostlyIsolate_w_GOP_FE", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")

*Mostly Isolating-B
twoway rcap gub glb mnum if fig=="M1b", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M1b", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M1b", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M1b", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("MostlyIsolate_w_GOP", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")


*Very Worry Ill-FIX Ef A
twoway rcap gub glb mnum if fig=="M2a", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M2a", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M2a", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M2a", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Worry_w_GOP_FE", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")

*Very Worry Ill-B
twoway rcap gub glb mnum if fig=="M2b", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M2b", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M2b", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M2b", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Worry_w_GOP", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")


*Mostly Remote-FIX Ef A
twoway rcap gub glb mnum if fig=="M3a", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M3a", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M3a", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M3a", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Remote_w_GOP_FE", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

*Mostly Remote-B
twoway rcap gub glb mnum if fig=="M3b", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M3b", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M3b", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M3b", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Remote_w_GOP", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

*Worn Mask-FIX Ef A
twoway rcap gub glb mnum if fig=="M4a", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M4a", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M4a", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M4a", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Mask_w_GOP_FE", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

*Worn Mask-B
twoway rcap gub glb mnum if fig=="M4b", lcolor(red) lwidth(thin) lpattern(dash) || scatter gco mnum if fig=="M4b", mcolor(red) msymbol(Oh)  ///
|| rcap dub dlb mnum if fig=="M4b", lcolor(blue) lwidth(thin) lpattern(solid) || scatter dco mnum if fig=="M4b", mcolor(blue) msymbol(Dh) ///
xlabel(3 "4/20"  4 " "  5 "6/20"  6 " "  7 "8/20"  8 " "  9 "10/20"  10 " "  11 "12/20" 12 " " 13 "2/22" 14 " " 15 "4/21" 16 " " 17 "6/21" 18 " " 19 "8/21" 20 " ") ///
legend(pos(6) col(2)) ///
legend(order (2 "Rep, 95% ci"  4 "Dem, 95% ci" ) ) ///
plotregion(color(white)) graphregion(color(white))   ///
yline(0, lc(black) lwidth(thin)) ///
xline(13 14 15 , lwidth(.5in) lc(gray*.2)) ///
xline(13 15, lc(gray*.2) lpattern(dot) lwidth(thin)) ///
saving("Mask_w_GOP", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate_w_GOP.gph Mask_w_GOP.gph Worry_w_GOP.gph Remote_w_GOP.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate_w_GOP.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S14.png", replace width(2200) height(1600)

grc1leg MostlyIsolate_w_GOP_FE.gph Mask_w_GOP_FE.gph Worry_w_GOP_FE.gph Remote_w_GOP_FE.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate_w_GOP_FE.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S15.png", replace width(2200) height(1600)

* Delete the intermediate files
erase MostlyIsolate_w_GOP.gph 
erase Mask_w_GOP.gph 
erase Worry_w_GOP.gph 
erase Remote_w_GOP.gph
erase MostlyIsolate_w_GOP_FE.gph 
erase Mask_w_GOP_FE.gph 
erase Worry_w_GOP_FE.gph 
erase Remote_w_GOP_FE.gph


******************
*** Figure S16 ***
******************

*Change in Effect of Income on Masking

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

tab month_num, gen(monthdum)

forval i=1/19 {
gen incomemonthdum`i'=income*monthdum`i'
}

*no individual fixed effects
reghdfe worn_mask dem indep_third incomemonthdum3-incomemonthdum18 dmonthdum4-dmonthdum20  imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed live_w_children income  Y3h6_facialcoverings male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial [aw=WEIGHT] , a(time ctyfip) vce(cl ctyfip)
estimates store nofes

*individual fixed effects
reghdfe worn_mask dem indep_third incomemonthdum3-incomemonthdum18 dmonthdum4-dmonthdum20  imonthdum4-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4 , a(time pid) vce(cl ctyfip)
estimates store fes

quietly  coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(incomemonthdum3 incomemonthdum4 incomemonthdum5 incomemonthdum6 incomemonthdum7 incomemonthdum8 incomemonthdum9 incomemonthdum10 incomemonthdum11 incomemonthdum12 incomemonthdum13 incomemonthdum14 incomemonthdum15 incomemonthdum16 incomemonthdum17 incomemonthdum18) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(incomemonthdum3 incomemonthdum4 incomemonthdum5 incomemonthdum6 incomemonthdum7 incomemonthdum8 incomemonthdum9 incomemonthdum10 incomemonthdum11 incomemonthdum12 incomemonthdum13 incomemonthdum14 incomemonthdum15 incomemonthdum16 incomemonthdum17 incomemonthdum18)), vertical ///
coeflabels (incomemonthdum2="4/20" incomemonthdum3="5/20" incomemonthdum4="6/20" incomemonthdum5="7/20" incomemonthdum6="8/20" incomemonthdum7="9/20" incomemonthdum8="10/20" incomemonthdum9="11/20" incomemonthdum10="12/20" incomemonthdum11="1/21" incomemonthdum12="2/21" incomemonthdum13="3/21" incomemonthdum14="4/21" incomemonthdum15="5/21" incomemonthdum16="6/21" incomemonthdum17="7/21" incomemonthdum18="8/21" incomemonthdum19="9/21" )  xlabel(, angle(45)) ///
legend(position(6) rows(1)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask_Income_Interaction.gph", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")

graph export "figures\Figure S16.png", replace

* Delete the intermediate files
erase Mask_Income_Interaction.gph


******************
*** Figure S17 ***
******************

*Change in Partisan Gap in COVID-19 Responses, Controlling for Vaccination Status

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

*Mostly Isolate

estimates clear
reghdfe Mostly_Isol vaccinated  dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20  Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_fe_model [aw=WEIGHT]  if minmonthisol==3 ,  a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe Mostly_Isol vaccinated dem indep_third dmonthdum3-dmonthdum20 imonthdum3-imonthdum20 Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model $controls_fe_model  [aw=WEIGHT],  a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(dmonthdum3	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("MostlyIsolate", replace) ///
title("Mostly Isolating (base month March 2020)") xtitle("Pandemic Month")

*Worn masks

tab month_number if worn_mask!=.

estimates clear
reghdfe worn_mask vaccinated dem indep_third dmonthdum4-dmonthdum20 imonthdum2 imonthdum4-imonthdum20  $controls_fe_model  Y3h6_facialcoverings [aw=WEIGHT]  if minmonthmask==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe worn_mask vaccinated dem indep_third dmonthdum4-dmonthdum20 imonthdum2 imonthdum4-imonthdum20 $controls_fe_model  Y3h6_facialcoverings $controls_main_model [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Mask", replace) ///
title("Worn mask (base month April 2020)") xtitle("Pandemic Month")


*Very Worried Ill

estimates clear
reghdfe v_worry_ill vaccinated dem indep_third  dmonthdum4-dmonthdum20 imonthdum2 imonthdum4-imonthdum20  $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT]  if minmonthworry==4  , a(time pid) vce(cl ctyfip)
estimates store fes

reghdfe v_worry_ill vaccinated dem indep_third dmonthdum4-dmonthdum20 imonthdum2 imonthdum4-imonthdum20 $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements $controls_main_model  [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Worry", replace) ///
title("Very worried about COVID (base month April 2020)") xtitle("Pandemic Month")


*Mostly remote

estimates clear
reghdfe mostly_remote vaccinated dem indep_third dmonthdum5-dmonthdum20 imonthdum5-imonthdum20  ZLNpc_new_cases_7day  live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if (minmonthmostly_remote==4 | minmonthmostly_remote==5)  &  employed==1, a(time pid) vce(cl ctyfip)
estimates store fes
reghdfe mostly_remote vaccinated dem indep_third dmonthdum5-dmonthdum20 imonthdum5-imonthdum20 ZLNpc_new_cases_7day  live_w_children income Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  $controls_main_model  if  employed==1 [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(12 13, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum4	dmonthdum5	dmonthdum6	dmonthdum7	dmonthdum8	dmonthdum9	dmonthdum10	dmonthdum11	dmonthdum12	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels (dmonthdum3="4/20" dmonthdum4="5/20" dmonthdum5="6/20" dmonthdum6="7/20" dmonthdum7="8/20" dmonthdum8="9/20" dmonthdum9="10/20" dmonthdum10="11/20" dmonthdum11="12/20" dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Remote", replace) ///
title("Mostly working remote (base month May 2020)") xtitle("Pandemic Month")

grc1leg MostlyIsolate.gph Mask.gph Worry.gph Remote.gph   ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(MostlyIsolate.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S17.png", replace width(2200) height(1600)

* Delete the intermediate files
erase MostlyIsolate.gph 
erase Mask.gph 
erase Worry.gph 
erase Remote.gph


******************
*** Figure S18 *** 
******************

*Change in Partisan Gap in Vaccination Status

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

estimates clear
reghdfe vaccinated dem indep_third dmonthdum13-dmonthdum20 imonthdum13-imonthdum20  $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  [aw=WEIGHT]  if minmonthvac==3, a(time pid) vce(cl ctyfip)
estimates store fes
reghdfe vaccinated dem indep_third dmonthdum13-dmonthdum20 imonthdum13-imonthdum20 $controls_fe_model Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing  $controls_main_model   [aw=WEIGHT], a(time ctyfip) vce(cl ctyfip)
estimates store nofes

coefplot (fes, label(With Individual FEs) xline(2 3, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels ( dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Vac", replace) ///
title("Vaccinated (base month Jan 2021)") xtitle("Pandemic Month")
graph export "figures\Figure S18.png", replace

* Delete the intermediate files
erase Vac.gph

******************
*** Figure S19 *** 
******************

*Age, Partisanship, and Vaccination Status

clear
use "data_gallup.dta"

*Determine when respondent was first observed
gen month_number=month
forval x=1/9 {
replace month_number=12+`x' if year==2021 & month==`x'
}
egen minmonthvac=min(month_number) if vaccinated!=., by(pid)
egen minmonthmask=min(month_number) if worn_mask!=., by(pid)
egen minmonthisol=min(month_number) if Mostly_Isol!=., by(pid)
egen minmonthworry=min(month_number) if v_worry_ill!=., by(pid)
egen minmonthmostly_remote=min(month_number) if mostly_remote!=., by(pid)

**Older pop, 65+
*no individual fixed effects
reghdfe vaccinated dem indep_third  dmonthdum13-dmonthdum20 imonthdum14-imonthdum20 ZLNpc_new_cases_7day out_workforce employed live_w_children income   male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing [aw=WEIGHT] if month_num>=13 & month_num!=. & age_group4==1, a(time ctyfip) vce(cl ctyfip)
estimates store nofes

*individual fixed effects
reghdfe vaccinated dem indep_third  dmonthdum13-dmonthdum20 imonthdum14-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income  Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing [aw=WEIGHT]  if month_num>=13 & month_num!=. & age_group4==1, a(time pid) vce(cl ctyfip)
estimates store fes

coefplot (fes, label(With Individual FEs) xline(2 3, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels ( dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
legend(position(6) rows(1)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Vac_65_plus.gph", replace) ///
title("Vaccination status: Age>=65 (base month Jan 2021)") xtitle("Pandemic Month")

*Younger pop, under 65
*no individual fixed effects
reghdfe vaccinated dem indep_third  dmonthdum13-dmonthdum20  imonthdum14-imonthdum20  ZLNpc_new_cases_7day out_workforce employed live_w_children income   male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing [aw=WEIGHT] if month_num>=13 & month_num!=. & age_group4==0, a(time ctyfip) vce(cl ctyfip)
estimates store nofes

*individual fixed effects
reghdfe vaccinated dem indep_third  dmonthdum13-dmonthdum20  imonthdum14-imonthdum20  ZLNpc_new_cases_7day out_workforce employed income  Yc4_restrictionsongatherings Yc6_stayathomerequirements Yc2_workplaceclosing [aw=WEIGHT]  if month_num>=13 & month_num!=. & age_group4==0, a(time pid) vce(cl ctyfip)
estimates store fes

coefplot (fes, label(With Individual FEs) xline(2 3, lwidth(.5in) lc(gray*.2)) mcolor(blue) ciopts(lcolor(blue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20) ///
yline(0, lcolor(black) lwidth(thin) lpattern(dash))) ///
(nofes, label (Without Individual FEs) mcolor( eltblue) ciopts(lcolor( eltblue)) ///
keep(	dmonthdum13	dmonthdum14	dmonthdum15	dmonthdum16	dmonthdum17	dmonthdum18	dmonthdum19	dmonthdum20)), vertical ///
coeflabels ( dmonthdum12="1/21" dmonthdum13="2/21" dmonthdum14="3/21" dmonthdum15="4/21" dmonthdum16="5/21" dmonthdum17="6/21" dmonthdum18="7/21" dmonthdum19="8/21" dmonthdum20="9/21")  xlabel(, angle(45)) ///
legend(position(6) rows(1)) ///
plotregion(color(white)) graphregion(color(white))   ///
saving("Vac_under65.gph", replace) ///
title("Vaccination status: Age<65 (base month Jan 2021)") xtitle("Pandemic Month")

* Save plot
grc1leg Vac_under65.gph Vac_65_plus.gph ///
, imargin(2 2 2 2) row(2) col(2) legendfrom(Vac_under65.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white))  
graph export "figures\Figure S19.png", replace width(2200) height(1100)

* Delete the intermediate files
erase Vac_under65.gph 
erase Vac_65_plus.gph


*****************
*** Table S20 ***
*****************

*Alternative Analyses for Table 1, Ever-Treated as Control Group

clear
use "data_gallup.dta"

// Create ever_vaccinated variable
bysort pid: egen ever_vac=max(vaccinated)

// Key variables
gen vac_dem=vaccinated*dem
gen vac_ind=vaccinated*indep_third
gen vac_gop=vaccinated*gop

label variable vac_dem "Vaccinated x Democrat"
label variable vac_ind "Vaccinated x Independent"

*TWFE, ever-treated as control
reghdfe Mostly_Isol vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  if ever_vac==1  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S20 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated) replace 
reghdfe worn_mask vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  if ever_vac==1  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S20 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe v_worry_ill vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  if ever_vac==1  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S20 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe mostly_remote vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements  if ever_vac==1 & employed==1 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S20 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)

clear
use "stacked_did_data_ever_treated.dta"

gen _cohort_unit = st_unit
gen _cohort_time = st_time
gen _cohort = Cohort

label variable dem_vac "Vaccinated x Democrat"
label variable ind_vac "Vaccinated x Independent"
label variable vaccinated "Vaccinated"

*Estimate Stacked DID, ever-treated as control group
stackdid Mostly_Isol dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table S20 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated) replace 
stackdid worn_mask dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table S20 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)
stackdid v_worry_ill dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table S20 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)
stackdid mostly_remote dem_vac ind_vac vaccinated dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements if employed==1 [aw=WEIGHT],  vce(cl _cohort_unit) nobuild tr(vaccinated) group(_cohort_unit) 
outreg2 using "tables\Table S20 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(dem_vac ind_vac vaccinated)


******************
*** Figure S21 ***
******************

* Pre-trend Responses, Ever Vaccinated versus Never Vaccinated
* See R script Figures_made_in_R.R 


*****************
*** Table S22 ***
*****************

*Alternative TWFE Analysis of Pre- versus Post- Vaccination Status

clear
use "data_gallup.dta"

// Create ever_vaccinated variable
bysort pid: egen ever_vac=max(vaccinated)

// Key variables
gen vac_dem=vaccinated*dem
gen vac_ind=vaccinated*indep_third
gen vac_gop=vaccinated*gop

* Sort the data by pid and time
sort pid time 
by pid: gen lag_v1 = vaccinated[_n-1]
by pid: gen lead_v1 = vaccinated[_n+1]

label variable lag_v1 "Lag vaccinated"
label variable lead_v1 "Lead vaccinated"
label variable vac_dem "Vaccinated x Democrat"
label variable vac_ind "Vaccinated x Independent"

* Top Panel: Two-way fixed effects, including never-treated
reghdfe Mostly_Isol vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 TOP PANEL.xls", excel adjr2 lab dec(3) replace keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe worn_mask vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third   ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe v_worry_ill vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third   ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe mostly_remote vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third   ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements if employed==1 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)

*Brandice: mostly_remote is off

* Lower Panel: Two-way fixed effects, excluding never-treated
reghdfe Mostly_Isol vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements [aw=WEIGHT] if ever_vac==1,  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 LOWER PANEL.xls", excel adjr2 lab dec(3) replace keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe worn_mask vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements if ever_vac==1 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe v_worry_ill vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third  ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements if ever_vac [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)
reghdfe mostly_remote vac_dem vac_ind vaccinated lag_v1 lead_v1 dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements if employed==1 & ever_vac==1 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S22 LOWER PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated lag_v1 lead_v1)


*****************
*** Table S23 ***
*****************

* Alternative TWFE Difference-in-differences, Party Identification 

clear
use "data_gallup.dta"

// Create ever_vaccinated variable
bysort pid: egen ever_vac=max(vaccinated)

// Key variables
gen vac_dem=vaccinated*dem
gen vac_ind=vaccinated*indep_third
gen vac_gop=vaccinated*gop

egen minparty=min(party), by(pid)
egen maxparty=max(party), by(pid)
gen switchparty=1 if minparty!=maxparty
replace switchparty=0 if minparty==maxparty

sort pid time
iis pid
tis time
by pid: gen firstinpanel=1 if _n==1
by pid: replace firstinpanel=0 if _n!=1

gen firstdem=1 if firstinpanel==1 & dem==1
replace firstdem=0 if firstinpanel==1 & dem==0
bysort pid (firstdem): replace firstdem= firstdem[1]

gen firstindep=1 if firstinpanel==1 & indep==1
replace firstindep=0 if firstinpanel==1 & indep==0
bysort pid (firstindep): replace firstindep= firstindep[1]

gen firstgop=1 if firstinpanel==1 & gop==1
replace firstgop=0 if firstinpanel==1 & gop==0
bysort pid (firstgop): replace firstgop= firstgop[1]

label variable vac_dem "Vaccinated x Democrat"
label variable vac_ind "Vaccinated x Independent"

*Estimate TWFE model without party switchers
reghdfe Mostly_Isol vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements if switchparty==0 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 TOP PANEL.xls", excel adjr2 lab dec(3) replace keep(vac_dem vac_ind vaccinated)
reghdfe worn_mask vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements if switchparty==0 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe v_worry_ill vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements if switchparty==0 [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)
reghdfe mostly_remote vac_dem vac_ind vaccinated dem indep_third ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT] if employed==1 & switchparty==0,  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 TOP PANEL.xls", excel adjr2 lab dec(3) keep(vac_dem vac_ind vaccinated)

*Estimate TWFE model based on first party
gen vac_firstdem=vaccinated*firstdem
gen vac_firstindep=vaccinated*firstindep

label variable vac_firstdem "Vaccinated x Democrat"
label variable vac_firstindep "Vaccinated x Independent"

reghdfe Mostly_Isol vac_firstdem vac_firstind vaccinated firstdem firstindep ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 LOWER PANEL.xls", excel adjr2 lab dec(3) replace keep(vac_firstdem vac_firstind vaccinated)
reghdfe worn_mask vac_firstdem vac_firstind vaccinated firstdem firstindep ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 LOWER PANEL.xls", excel adjr2 lab dec(3)  keep(vac_firstdem vac_firstind vaccinated)
reghdfe v_worry_ill vac_firstdem vac_firstind vaccinated firstdem firstindep ZLNpc_new_cases_7day out_workforce employed income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT],  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 LOWER PANEL.xls", excel adjr2 lab dec(3)  keep(vac_firstdem vac_firstind vaccinated)
reghdfe mostly_remote vac_firstdem vac_firstind vaccinated firstdem firstindep ZLNpc_new_cases_7day income Yc4_restrictionsongatherings Yc6_stayathomerequirements  [aw=WEIGHT] if employed==1 ,  a(pid time) vce(cl pid)
outreg2 using "tables\Table S23 LOWER PANEL.xls", excel adjr2 lab dec(3)  keep(vac_firstdem vac_firstind vaccinated)


******************
*** Figure S24 ***
******************

*Map of Gatherings Restrictions and Stay-at-Home Orders 
* See R script Figures_made_in_R.R 

******************
*** Figure S25 ***
******************

*Nominal versus Effective Samples for Table 2
* See R script Figures_made_in_R.R 

*****************
*** Table S26 ***
*****************

*Control Variable Estimates for Table 2 

clear
use "data_gallup.dta"

label variable LNpc_new_cases_7day "Log per capita COVID-19 cases (county)"
label variable out_workforce "Out of workforce"
label variable AmerInd "American Indian or Native Hawaiian"
label variable age10 "Age"
label variable age_group4 "Age 65 and up (indicator)"
label variable somecol "Some college"
label variable income "Income"


*GOP governors only
reghdfe approvestate dem indep ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) replace keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)

reghdfe approvestate  dem indep demrestrictionsongatherings Yc4_restrictionsongatherings indrestrictionsongatherings  ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)

reghdfe approvestate  dem indep demstay Yc6_stayathome indstay ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)

*DEM governors only
reghdfe approvestate gop indep ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income  if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)

reghdfe approvestate  gop indep goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings  ///
ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)

reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S26.xls", excel adjr2 lab dec(3) keep(ZLNpc_new_cases_7day employed out_workforce male  Black Hisp Asian AmerInd  Multiracial age10 age_group4 somecol ba grad live_w_children income)


******************
*** Figure S27 ***
******************

* Marginal Predictions for Table 2

clear
use "data_gallup.dta"

gen party_recode=party
recode party_recode (3=1) (1=3)

label define prec 3 "Dem." 2 "Indep." 1 "Repub." , replace
label values party_recode prec

*Columns 3 and 4
reghdfe approvestate  party_recode##Yc4_restrictionsongatherings  ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
margins party_recode##Yc4_restrictionsongatherings
marginsplot
marginsplot, saving(app1, replace)  ///
ci1opts(lc(green) lp(dash))  plot1opts(lc(green) connect(none) mc(green) mlcolor(green) msymbol(Dh)) ///
ci2opts(lc(blue) lp(dash))  plot2opts(lc(blue) connect(none) mc(blue) mlcolor(blue) msymbol(Oh)) ///
xtitle("") title("Predicted approval of Republican governor" "by whether restrictions on gatherings are in effect") plot3opts(lc(none) mc(none)) ci3opts(col(none)) leg(pos(6) order(1 "Not in effect" 2 "In effect" 3 "") rows(1) rowgap(*1.5) colgap(*1.5) )


reghdfe approvestate  party_recode##Yc6_stayathome ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
margins party_recode##Yc6_stayathom
marginsplot, saving(app2, replace) ///
ci1opts(lc(green) lp(dash))  plot1opts(lc(green) connect(none) mc(green) mlcolor(green) msymbol(Dh)) ///
ci2opts(lc(blue) lp(dash))  plot2opts(lc(blue) connect(none) mc(blue) mlcolor(blue) msymbol(Oh)) ///
xtitle("") title("Predicted approval of Republican governor" "by whether stay-at-home order is in effect") plot3opts(lc(none) mc(none)) ci3opts(col(none)) leg(pos(6) order(1 "Not in effect" 2 "In effect" 3 "") rows(1) rowgap(*1.5) colgap(*1.5))

 
*Columns 5 and 6
reghdfe approvestate  party_recode##Yc4_restrictionsongatherings   ///
LNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
margins party_recode##Yc4_restrictionsongatherings
marginsplot, saving(app3, replace)  ///
ci1opts(lc(green) lp(dash))  plot1opts(lc(green) connect(none) mc(green) mlcolor(green) msymbol(Dh)) ///
ci2opts(lc(blue) lp(dash))  plot2opts(lc(blue) connect(none) mc(blue) mlcolor(blue) msymbol(Oh)) ///
xtitle("") title("Predicted approval of Democratic governor" "by whether restrictions on gatherings are in place") plot3opts(lc(none) mc(none)) ci3opts(col(none)) leg(pos(6) order(1 "Not in effect" 2 "In effect" 3 "") rows(1) rowgap(*1.5) colgap(*1.5))

reghdfe approvestate  party_recode##Yc6_stayathome ///
LNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
margins party_recode##Yc6_stayathom
marginsplot, saving(app4, replace) ///
ci1opts(lc(green) lp(dash))  plot1opts(lc(green) connect(none) mc(green) mlcolor(green) msymbol(Dh)) ///
ci2opts(lc(blue) lp(dash))  plot2opts(lc(blue) connect(none) mc(blue) mlcolor(blue) msymbol(Oh)) ///
xtitle("") title("Predicted approval of Democratic governor" "by whether stay-at-home order is in place") plot3opts(lc(none) mc(none)) ci3opts(col(none)) leg(pos(6) order(1 "Not in effect" 2 "In effect" 3 "") rows(1) rowgap(*1.5) colgap(*1.5))


grc1leg  app1.gph app2.gph app3.gph app4.gph     ///
, imargin(2 2 2 2) row(2) col(2)  legendfrom(app1.gph) iscale(*.75) plotregion(color(white)) graphregion(color(white)) 
graph export "figures\Figure S27.png", replace width(2200) height(1600)

* Delete the intermediate files
erase app1.gph
erase app2.gph
erase app3.gph
erase app4.gph


*****************
*** Table S28 ***
*****************

*Alternative Analyses for Table 2

clear
use "data_gallup.dta"


*Column 1 
*result still holds for states for which gatherings is not the first policy (footnote/supp)
gen gathfirst=1 if state=="Alabama" | state=="Alaska" | state=="California" | state=="Colorado" | state=="Delaware" | state=="Indiana" | state=="Iowa" | state=="Kansas" | state=="Maine" | state=="Maryland" | state=="Michigan" | state=="Minnesota" | state=="Missouri" | state=="New Jersey" | state=="New Mexico" | state=="North Carolina" | state=="Oregon" | state=="South Carolina" | state=="Vermont" | state=="Wisconsin"
replace gathfirst=0 if gathfirst==.

reghdfe approvestate dem indep demrestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income /// 
if gopgovernor==1 & gathfirst==0 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) replace keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Columns 2 and 3, no state fixed effects
reghdfe approvestate dem indep demrestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate dem indep demstay indstay Yc6_stayathome ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if gopgovernor==1 [aw=WEIGHT], a(time) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Column 4, Only SAHO states
gen nostayathome=0
replace nostayathome=1 if state=="Arizona" | state=="New Mexico" | state=="Utah" | state=="Nevada" | state=="Wyoming" | state=="North Dakota" | state=="South Daktoa" | state=="Nebraska" | state=="Kansas" | state=="Kowa" | state=="Arkansas" | state=="Mississippi" | state=="Maryland" | state=="Connecticut" | state=="Massachusetts" 

reghdfe approvestate  dem indep demstay indstay Yc6_stayathome ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if gopgovernor==1 & nostay==0 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Column 5 and 6, gatherings according to whether considered avoiding gatherings
gen avoidedgath=1 if C9B==1 | C9B==2
replace avoidedgath=0 if C9B==3

*If purely teamsmanship, then effect should extend to Dems who have not considered avoiding gatherings
reghdfe approvestate  dem indep demrestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income if gopgovernor==1 & avoidedgath==0 [aw=WEIGHT] , a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*but does hold for those who either have avoided or considered doing so
reghdfe approvestate  dem indep demrestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income if gopgovernor==1 & avoidedgath==1 [aw=WEIGHT] , a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Column 7, result on SAHOs holds for states that did not include it as a first policy
*Hawaii is the only state to enact a SAHO as a first policy
reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 & state!="Hawaii" [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Columns 8 and 9, what if no state fixed effects
reghdfe approvestate  gop indep goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings  ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 [aw=WEIGHT], a(time) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Column 10, only SAHO states
reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 & nostay==0 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*Columns 11 and 12, party teamsmanship

*versus not very likely to do so (somewhat likely, somehwat unlikely, or very unlikely)
reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 & C4_1>1 & C4_1<5 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)

*respondents who are very likely to isolate if public health officials recommend doing so
reghdfe approvestate  gop indep  gopstay indstay Yc6_stayathome ///
ZLNpc_new_cases_7day out_workforce employed male age10 age_group4   somecol ba grad AmerInd Asian Black Hisp Multiracial live_w_children income ///
if demgovernor==1 & C4_1==1 [aw=WEIGHT], a(time stateid) vce(cl stateid)
outreg2 using "tables\Table S28.xls", excel adjr2 lab dec(3) keep(dem gop indep demrestrictionsongatherings goprestrictionsongatherings indrestrictionsongatherings Yc4_restrictionsongatherings demstay gopstay indstay Yc6_stayathome)


